package net.oschina.app.adapter.my;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import net.oschina.app.R;
import net.oschina.app.adapter.BaseRecyclerViewAdapter;
import net.oschina.app.bean.Favorite;

import java.util.List;

/**
 * Created by YL on 2017/4/1.
 */
public class FavoriteRecyclerAdapter extends BaseRecyclerViewAdapter {
    private List<Favorite> flist;

    public FavoriteRecyclerAdapter(List<Favorite> favoriteList) {
        this.flist = favoriteList;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View itemView = mInflater.inflate(R.layout.favorite_item,parent,false);
        FavoritViewHolder holder = new FavoritViewHolder(itemView);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        super.onBindViewHolder(holder, position);
        FavoritViewHolder viewHolder = (FavoritViewHolder) holder;
        Favorite favorite = flist.get(position);
        viewHolder.mTextView.setText(favorite.getTitle());
    }

    @Override
    public int getItemCount() {
        return flist.size();
    }

    public class FavoritViewHolder extends RecyclerView.ViewHolder {

        public TextView mTextView;

        public FavoritViewHolder(View itemView) {
            super(itemView);
            mTextView = (TextView) itemView.findViewById(R.id.favorite_tv);
        }
    }

    @Override
    public int getItemViewType(int position) {
        return super.getItemViewType(position);
    }
}
